package main

import (
	"fmt"
	"github.com/Shopify/sarama"
	"log"
)

func main() {
	config := sarama.NewConfig()
	consumer,err := sarama.NewConsumer([]string{"10.1.81.55:9092:"}, config)
	defer consumer.Close()

	partitionConsumer,err := consumer.ConsumePartition("test", 0, sarama.OffsetOldest)
	if err != nil {
		log.Fatal(err)
	}
	defer partitionConsumer.Close()

	for {
		select {
			case msg := <-partitionConsumer.Messages():
				fmt.Printf("msg offset :%d, partition:%d, timestamp: %s", msg.Offset, msg.Partition, msg.Timestamp.String())
			case err := <-partitionConsumer.Errors():
				fmt.Printf("err :%s\n", err.Error())
		}
	}
}